diff --git a/swh/web/browse/snapshot_context.py b/swh/web/browse/snapshot_context.py --- a/swh/web/browse/snapshot_context.py +++ b/swh/web/browse/snapshot_context.py @@ -30,6 +30,7 @@ get_directory_entries, gen_directory_link, gen_revision_link, + gen_revision_url, request_content, gen_content_link, prepare_content_for_display, @@ -588,7 +589,24 @@ browse_view_name, url_args=url_args, query_params=release_query_params, ) - return SnapshotContext( + revision_info = None + if revision_id: + try: + revision_info = service.lookup_revision(revision_id) + except NotFoundExc: + pass + else: + revision_info["date"] = format_utc_iso_date(revision_info["date"]) + revision_info["committer_date"] = format_utc_iso_date( + revision_info["committer_date"] + ) + if revision_info["message"]: + message_lines = revision_info["message"].split("\n") + revision_info["message_header"] = message_lines[0] + else: + revision_info["message_header"] = "" + + snapshot_context = SnapshotContext( branch=branch_name, branches=branches, branches_url=branches_url, @@ -601,6 +619,7 @@ releases=releases, releases_url=releases_url, revision_id=revision_id, + revision_info=revision_info, root_directory=root_directory, snapshot_id=snapshot_id, snapshot_sizes=snapshot_sizes, @@ -609,6 +628,11 @@ visit_info=visit_info, ) + if revision_info: + revision_info["revision_url"] = gen_revision_url(revision_id, snapshot_context) + + return snapshot_context + def _build_breadcrumbs(snapshot_context: SnapshotContext, path: str): origin_info = snapshot_context["origin_info"] diff --git a/swh/web/common/typing.py b/swh/web/common/typing.py --- a/swh/web/common/typing.py +++ b/swh/web/common/typing.py @@ -75,7 +75,7 @@ class SnapshotContext(TypedDict): branch: Optional[str] - """optional branch name set when browsing snapshot int that scope""" + """optional branch name set when browsing snapshot in that scope""" branches: List[SnapshotBranchInfo] """list of snapshot branches (possibly truncated)""" branches_url: str @@ -89,15 +89,17 @@ query_params: QueryParameters """common query parameters when browsing snapshot content""" release: Optional[str] - """optional release name set when browsing snapshot int that scope""" + """optional release name set when browsing snapshot in that scope""" release_id: Optional[str] - """optional release identifier set when browsing snapshot int that scope""" + """optional release identifier set when browsing snapshot in that scope""" releases: List[SnapshotReleaseInfo] """list of snapshot releases (possibly truncated)""" releases_url: str """snapshot releases list browse URL""" revision_id: Optional[str] - """optional revision identifier set when browsing snapshot int that scope""" + """optional revision identifier set when browsing snapshot in that scope""" + revision_info: Optional[Dict[str, Any]] + """optional revision info set when browsing snapshot in that scope""" root_directory: Optional[str] """optional root directory identifier set when browsing snapshot content""" snapshot_id: str diff --git a/swh/web/templates/includes/content-display.html b/swh/web/templates/includes/content-display.html --- a/swh/web/templates/includes/content-display.html +++ b/swh/web/templates/includes/content-display.html @@ -1,5 +1,5 @@ {% comment %} -Copyright (C) 2017-2019 The Software Heritage developers +Copyright (C) 2017-2020 The Software Heritage developers See the AUTHORS file at the top-level directory of this distribution License: GNU Affero General Public License version 3, or any later version See top-level LICENSE file for more information @@ -7,6 +7,8 @@ {% load swh_templatetags %} +{% include "includes/revision-info.html" %} + {% if snapshot_context and snapshot_context.is_empty %} {% include "includes/empty-snapshot.html" %} {% else %} diff --git a/swh/web/templates/includes/directory-display.html b/swh/web/templates/includes/directory-display.html --- a/swh/web/templates/includes/directory-display.html +++ b/swh/web/templates/includes/directory-display.html @@ -1,10 +1,12 @@ {% comment %} -Copyright (C) 2017-2019 The Software Heritage developers +Copyright (C) 2017-2020 The Software Heritage developers See the AUTHORS file at the top-level directory of this distribution License: GNU Affero General Public License version 3, or any later version See top-level LICENSE file for more information {% endcomment %} +{% include "includes/revision-info.html" %} + {% if snapshot_context and snapshot_context.is_empty %} {% include "includes/empty-snapshot.html" %} {% elif dirs|length > 0 or files|length > 0 %} diff --git a/swh/web/templates/includes/revision-info.html b/swh/web/templates/includes/revision-info.html new file mode 100644 --- /dev/null +++ b/swh/web/templates/includes/revision-info.html @@ -0,0 +1,35 @@ +{% comment %} +Copyright (C) 2020 The Software Heritage developers +See the AUTHORS file at the top-level directory of this distribution +License: GNU Affero General Public License version 3, or any later version +See top-level LICENSE file for more information +{% endcomment %} + +{% if snapshot_context and snapshot_context.revision_id %} +